<?php
   $lang = PFactory::getLanguage();
   $lang->load("com_jobs", JPATH_SITE, "zh-CN");
   $basicdemands = $skilldemands = $langdemands = '';

   $jobdemands = $_['jobdemands'];
   foreach($jobdemands as $k=>$v){
       $expected_answer = $v['expected_answer'];
      if($expected_answer){ 
         switch($v['alias']){
            case 'LANG':
               $choices = json_decode($v['choices']);
               $langdemands .= '<div class="control-group clearfix">
                                   <label class="control-label key pull-left" for="" style="width:auto;">'.$v['text_hr'].':</label>
                                   <div class="controls pull-left" style="margin-left:4px;">
                                      <span class="mounthnum">'.$choices->$expected_answer.'</span>
                                   </div>
                                </div>';
            break;
            case 'SKILL':
               $choices = json_decode($v['choices']);
               $skilllevel = '';
               if(is_numeric($expected_answer)){
                  $exp = $expected_answer;
               }else{
                  $expected_answer = json_decode($expected_answer);
                  if(!empty($expected_answer->level)){
                     $level = $expected_answer->level;
                     //level 了解 change to 普通
                     if($level == PJobpositionHelper::SKILL_LEVEL_KNOW){
                        $level = PJobpositionHelper::SKILL_LEVEL_GENERALE;
                     }
                     $skilllevel = $choices->$level;
                  }
                  $exp = empty($expected_answer->exp)?'':$expected_answer->exp;
               }
               $skilldemands .= '<div class="control-group">
                                   <label class="control-label longwidth" for="" title="'.(compact_strlen($v['text_hr']) >= 12 ? $v['text_hr'] : '').'"><b class="longwidth">'.$v['text_hr'].'</b><em>:</em></label>
                                   <div class="controls longmarginleft">
                                       <span class="exp_select">'.$skilllevel.'</span>
                                       <span class="mounthnum">'.$exp.'</span><span class="mounth">月</span><span class="txtabove">以上</span>
                                   </div>
                                </div>'; 
            break;
            case 'SALARY':
               $basicdemands .= '<div class="control-group">
                                   <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                   <div class="controls">
                                       <span class="mounthnum">'.strmaxwordlen($expected_answer,12).'</span><span class="txtabove">以下</span>
                                   </div>
                                </div>';
            break;
            case 'DEGREE':
               $choices = json_decode($v['choices']);
               $basicdemands .= '<div class="control-group">
                                   <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                   <div class="controls">
                                      <span class="mounthnum">'.$choices->$expected_answer.'</span><span class="txtabove">以上</span>
                                   </div>
                                 </div>';
            break;
            case 'ENTRY_DEADLINE':
               $choices = json_decode($v['choices']);
               $basicdemands .= '<div class="control-group">
                                   <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                   <div class="controls">
                                      <span class="mounthnum">'.$choices->$expected_answer.'</span>
                                   </div>
                                 </div>';
            break;
            case 'INDUSTRY':
               $expected_answer = JobHelper::getSelectIndustry2($expected_answer);
               $basicdemands .= '<div class="control-group">
                                   <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                   <div class="controls">
                                      <span class="mounthnum">'.JText::_($expected_answer).'</span>
                                   </div>
                                 </div>';
            break;
            case 'LOCATION':
               $basicdemands .= '<div class="control-group">
                                   <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                   <div class="controls">
                                      <span class="mounthnum">'.$expected_answer.'</span>
                                   </div>
                                 </div>';
            break;
            case 'AGE':
               $basicdemands .= '<div class="control-group">
                                   <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                   <div class="controls">
                                      <span class="mounthnum">'.$expected_answer.'</span>
                                   </div>
                                 </div>';
            break;
            case 'SEX':
               $expected_answer = $expected_answer==1 ? '男' : '女';
               $basicdemands .= '<div class="control-group">
                                   <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                   <div class="controls">
                                      <span class="mounthnum">'.$expected_answer.'</span>
                                   </div>
                                 </div>';
            break;
            case 'WORK_EXP':
               $basicdemands .= '<div class="control-group">
                                   <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                   <div class="controls">
                                      <span class="mounthnum">'.strmaxwordlen($expected_answer,12).' 年</span><span class="txtabove">以上</span>
                                   </div>
                                 </div>';
            break;
            case 'MARRIAGE':
            
            $basicdemands .= '<div class="control-group">
                                 <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                 <div class="controls">
                                    <span class="mounthnum">希望了解</span>
                                 </div>
                              </div>';
            break;
            default:
               $basicdemands .= '<div class="control-group">
                                   <label class="control-label key" for="">'.$v['text_hr'].':</label>
                                   <div class="controls">
                                       <span class="mounthnum">'.$expected_answer.'</span>
                                   </div>
                                 </div>';
         }
      }
   }

   // create final match rules html 
   echo '<div class="requirehavedone">
         <div class="requirewrap">
            <div class="requiretitle yahei"><h6 class="normal">基本要求</h6></div>
            <div class="form-horizontal medium clearfix">
              '.$basicdemands.'
            </div>
         </div>
         <div class="requirewrap">
            <div class="requiretitle yahei"><h6 class="normal">技能要求</h6></div>
            <div class="form-horizontal medium clearfix needredoui">
              '.$skilldemands.'
            </div>
         </div>
         <div class="requirewrap">
            <div class="requiretitle yahei"><h6 class="normal">外语要求</h6></div>
            <div class="form-horizontal medium clearfix">
              '.$langdemands.'
            </div>
         </div>
         <div class="require_edit"><a href="javascript:;" class="ppp_bluebtn">编辑</a></div>
         </div>';
   
